#ifndef _HTREE_H
#define _HTREE_H

#include "buffer.h"
#include <sys/types.h>

struct h_node{
				char key[128];
				int hash;
				long value;
				long dat_len;
				struct h_node *subnodes;
				struct h_node *brother;
				char used;
				char num;
};

struct h_tree{
	int rd_fd;
    	int wr_fd;
    	off_t wr_index;
    	off_t rd_index;
	struct h_node *root;
	int idx_fd;
};

extern struct h_tree* new_htree();

/**存储或者更新一个K/V对*/
extern int save(struct h_tree *tree,const void *key,size_t key_len, struct buffer *val);
/**查找一个K/V对*/
extern int find(struct h_tree *tree,const void *key,size_t key_len, struct buffer *val);
/**移除一个K/V对*/
extern int take(struct h_tree *tree,const void *key,size_t key_len);

#endif // htree
